<template>
  <Swiper class="swclass">
    <!-- 使用这个v-for 要加 key -->
    <Swiperitem v-for="(item, index) in banner" :key="index">
      <!-- 超链接动态绑定 链接 -->
      <a :href="item.link">
        <!-- 动态绑定 图片的 src -->
        <img :src="item.image" alt="" @load="imageLoad" />
      </a>
    </Swiperitem>
  </Swiper>
</template>

<script>
import Swiper from "../components/swiper/Swiper.vue";
import Swiperitem from "../components/swiper/SwiperItem.vue";
export default {
  name: "HomeSwiper",
  props: {
    banner: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  components: {
    Swiper,
    Swiperitem,
  },
  data() {
    return {
      isLoad: false,
    };
  },
  methods: {
    imageLoad() {
      if (!this.isLoad) {
        this.$emit('swiperImageLoad');
        this.isLoad = true;
      }
    },
  },
};
</script>

<style>
.swclass {
  padding-top: 44px;
}
</style>